package com.chen.blue.config.mybatis;

import com.baomidou.mybatisplus.core.handlers.MetaObjectHandler;
import com.chen.blue.service.security.SecurityService;
import org.apache.ibatis.reflection.MetaObject;
import org.springframework.stereotype.Component;

/**
 * Created By CLT On 2024/6/20.
 */
@SuppressWarnings("all")
public class MybatisAutoFill implements MetaObjectHandler {


    @Override
    public void insertFill(MetaObject metaObject) {

        if (metaObject.getValue("creator") == null)
            this.strictInsertFill(metaObject, "creator", String.class, SecurityService.currentUserName());

    }

    @Override
    public void updateFill(MetaObject metaObject) {

        if (metaObject.getValue("updater") == null)
            this.strictUpdateFill(metaObject, "updater", String.class, SecurityService.currentUserName());

    }

}
